#!/bin/bash

echo "======================================"
echo "     服务发现测试脚本"
echo "======================================"

# 等待服务启动
echo "等待服务启动..."
sleep 10

# 测试Gateway健康检查
echo "1. 测试Gateway健康检查..."
curl -s http://localhost:8080/api/discovery/health
echo

# 测试获取所有服务列表
echo "2. 获取所有注册服务列表..."
curl -s http://localhost:8080/api/discovery/services | python -m json.tool
echo

# 测试获取user-service实例
echo "3. 获取user-service实例列表..."
curl -s http://localhost:8080/api/discovery/services/user-service/instances | python -m json.tool
echo

# 测试直接访问user-service
echo "4. 直接访问user-service健康检查..."
curl -s http://localhost:8001/actuator/health
echo

# 测试通过Gateway访问user-service
echo "5. 通过Gateway访问user-service..."
curl -s http://localhost:8080/api/user-service/actuator/health
echo

# 测试Nacos控制台
echo "6. 检查Nacos控制台服务列表..."
echo "请访问: http://localhost:8848/nacos"
echo "用户名: nacos, 密码: nacos"

echo "======================================"
echo "测试完成！"
echo "======================================" 